/*
 * This file is part of Jeve.

    Jeve is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    Jeve is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    Copyright 2007 Jochen Bedersdorfer (beders@yahoo.com)
 *
 */
package de.monoid.eve;

import java.util.HashMap;
import java.util.Map;

/** Root object to access various EVE online objects.
 * Simple implementation of a root object which gives access to the eve object model
 * 
 * @author beders
 *
 */
public class DataStore {
  private Map<String, Character> id2charMap = new HashMap<String, Character>();
  private EveInterface anInterface;
  
  /**
   * Create a new DataStore for the given eve account
   * @param anUserID the user id to use
   * @param anAPIKey the API key as generated by the eve online website
   */
  public DataStore(UserID anUserID, APIKey anAPIKey) {
    anInterface = new EveInterface(anUserID, anAPIKey);
  }
  
  /**
   * Get the character with the given id
   * @param anId the id of the character
   * @return the character object
   */
  public Character getCharacter(String anId) {
   Character ch = id2charMap.get(anId);
   if (ch == null) {
     ch = new Character(anInterface, anId);
     id2charMap.put(anId, ch);
   }
   return ch;
  }
}
